package com.nx.project.javacore.factory;


import lombok.Data;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@Data
public class BreakfastStore {
    public static void main(String[] args) throws IOException {
        BreakfastStore breakfastStore = new BreakfastStore();
        Breakfast breakfask =  breakfastStore.order(readConsole());
        if(breakfask != null){
            System.out.println("你好，一共消费："+breakfask.getPrice());
        }

    }

    private Breakfast order(String id) {
//        BreakfastFactory01 factory = new BreakfastFactory01();
//        return factory.create(id);

        BreakfastFactory02 factory = new BreakfastFactory02();
        try {
            return factory.create(id);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;


    }

    private static String readConsole() throws IOException {
        System.out.println("欢迎光临....");
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String input = bufferedReader.readLine();
        return input;
    }
}
